// Copyright 2012 Sergio, Raul, Dorival. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// STL
#include <iostream>
#include <cmath>

// GemLab
#include "gemlab.h"

using std::cout;
using std::endl;
using GemLab::Array;
using GemLab::String;

int main(int argc, char **argv) try
{
    // points
    Array<double> X(5), Y(5), Z(5);
    if (true) // problem with these points...
    //if (false) // problem with these points...
    {
        X.Resize(6);
        Y.Resize(6);
        Z.Resize(6);
        X = 0.0, 1.0, 1.0, 0.0, 0.5, 2.0;
        Y = 0.0, 0.0, 1.0, 1.0, 0.5, 2.0;
        Z = 1.0, 1.0, 1.0, 1.0, 0.5, 2.0;
    }
    else
    {
        X = 0.0, 1.0, 1.0, 0.0, 0.5;
        Y = 0.0, 0.0, 1.0, 1.0, 0.5;
        Z = 1.0, 1.0, 1.0, 1.0, 0.5;
    }

    // using CGAL
    {
        GemLab::Delaunay mesh(3); // 2D
        mesh.AddPoints (X, Y, Z);
        mesh.Generate  ();
        mesh.WriteVTU  ("ex_delau02_cgal");
        cout << " File <ex_delau02_cgal.vtu> generated\n";
    }

    // using TetGen
    {
        GemLab::UMesh mesh(3); // 2D
        mesh.Delaunay (X, Y, Z,/*Tag*/-1);
        mesh.WriteVTU ("ex_delau02_tetgen");
        cout << " File <ex_delau02_tetgen.vtu> generated\n";
    }

    return 0;
}
GEMLAB_CATCH
